package com.zjs.controller;

import com.zjs.pojo.User;
import com.zjs.serice.UserService;
import com.zjs.util.ResultStatus;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vo.AddUserVo;
import vo.UpdatePassword;

@RestController
@Slf4j
@Api(description = "用户API接口")
public class Controller {
    @Autowired
    UserService userService;

    /**
     * 登录
     * @param user
     * @return
     */
    @ApiOperation(value="PC用户登录", notes="根据用户名和密码进行登录", produces="application/json")
    @PostMapping(value = "login")
    public ResultStatus login (@RequestBody User user) {
        return userService.login(user);
    }

    /**
     * 修改密码
     * @param
     * @return
     */
    @ApiOperation(value="PC修改密码", notes="根据用户名和密码进行修改", produces="application/json")
    @PostMapping(value = "updetepassword")
    public ResultStatus updetepassword (@RequestBody UpdatePassword updatepassword) {
        return userService.updetepassword(updatepassword);
    }

    @ApiOperation(value="发送验证码", notes="根据手机号发送验证码", produces="application/json")
    @PostMapping(value = "/sendCode")
    public ResultStatus sendCode(@RequestBody User user) {
        return userService.sendCode(user);
    }


    @ApiOperation(value="买家用户注册", notes="买家用户进行注册", produces="application/json")
    @PostMapping(value = "/addUser")
    public ResultStatus addUser(@RequestBody AddUserVo addUserVo) {
        return userService.addUser(addUserVo);
    }



}
